#include <vector>
#include <stdexcept>
#include "grade.h"
#include "median.h"

using namespace std;

//TODO

double grade(double midterm, double final, double homework){
    return 0.2*midterm + 0.4*final + 0.4*homework;
}
double grade(double midterm, double final, const std::vector<double> & hw){
    if(hw.size()==0)
		throw domain_error("student has done no homework");
    double homework = median(hw);
    return grade(midterm, final,homework);
}

double Student_info::grade() const{
    try{
        return ::grade(midterm, final, homework);
    }
    catch(domain_error& e){
        return ::grade(midterm, final, 0.0);
    }
}


